import Request from '../static/js/request.js';
let request = new Request().http;

import UploadFile from '../static/js/upload.js';
let uploadFile = new UploadFile().http;

export default{
	logined:function(upJson){//用户登录
		return request({url:"/api/auth/login",data:upJson,bMsg:"登陆中",methods:"POST",type:1})
	},
	getWxUserinfo:function(upJson){//微信用户授权
		return request({url:"/api/auth/weapi",data:upJson,bMsg:"登陆中",methods:"POST",type:1})
	},
	getUserInfo:function(upJson){//获取用户信息
		return request({url:"/api/info/info_user",data:upJson,methods:"POST"})
	},
	editUserInfo:function(upJson){//编辑用户信息
		return request({url:"/api/user/modifyUser",data:upJson,back:true,type:3,eMsg:"修改成功"})
	},
	addClient:function(upJson,type){//增改商户
		if(type == 0){
			return request({url:"/api/customer/create",data:upJson,type:3, methods:"POST"})
		}else{
			return request({url:"/api/customer/update",data:upJson,type:3,eMsg:"修改成功",methods:"POST"})
		}
	},
	getClientTypeList:function(upJson){//获取商户类型列表
		return request({url:"/api/common/customer_type",data:upJson,methods:"POST"})
	},
	getClientList:function(upJson){//获取商户列表
		return request({url:"/api/customer/lists",data:upJson,methods:"POST"})
	},
	getClientDetails:function(upJson,type){//获取商户数据
		if(type == 0){//商户详情
			return request({url:"/api/customer/details",data:upJson, methods:"GET"})
		}else if(type == 1){//商户设备类别
			return request({url:"/api/customer/device_list",data:upJson, methods:"GET"})
		}else if(type == 2){//商户派工列表
			return request({url:"/api/work/lists",data:upJson, methods:"GET"})
		}else if(type == 3){//商户拜访列表
			return request({url:"/api/customer/visit_list",data:upJson, methods:"GET"})
		}else if(type == 4){//商户联系人列表
			return request({url:"/api/customer/contact_list",data:upJson, methods:"GET"})
		}
	},
	getClientOverTimeList:function(upJson){//获取逾期未拜访客户列表
		return request({url:"/api/merchant/overTime",data:upJson})
	},
	checkClientList:function(upJson){//获取客户查重列表
		return request({url:"/api/merchant/checkOnly",data:upJson})
	},
	getClientEquipmentClassify:function(upJson){//获取新增设备分类
		return request({url:"/api/merchant/getDeviceList",data:upJson})
	},
	getClientEquipmentDetail:function(upJson){//客户设备详情
		return request({url:"/api/customer/device_detail",data:upJson, methods:"GET"})
	},
	getDeviceRecord:function(upJson){//维修保养记录
		return request({url:"/api/customer/device_record",data:upJson, methods:"GET"})
	},
	addClientEquipment:function(upJson){//客户新增设备
		return request({url:"/api/customer/device_create",data:upJson,back:true,type:3,methods:"POST"})
	},
	editClientEquipment:function(upJson){//客户编辑设备
		return request({url:"/api/customer/device_update",data:upJson,back:true,type:3,methods:"POST"})
	},
	addClientPhone:function(upJson){//客户新增联系人
		return request({url:"/api/customer/update_contact",data:upJson,back:true,type:3,methods:"POST"})
	},
	addClientVisit:function(upJson,type){//客户新增拜访
		if(type == 0){
			return request({url:"/api/merchant/visitInfo",data:upJson})
		}else if(type == 1){
			return request({url:"/api/merchant/modifyVisit",data:upJson,back:true,type:3,eMsg:"修改成功"})
		}else if(type == 2){
			return request({url:"/api/customer/visit_answer",data:upJson,back:true,type:3,eMsg:"留言成功"})
		}else if(type == 4){
			return request({url:"/api/customer/visit_del",data:upJson,methods:"POST"})
		}else if(type == 5){
			return request({url:"/api/customer/visit_customer",data:upJson,back:true,type:3,methods:"POST"})
		}
	},
	getClientWorkClassify:function(upJson){//客户新增工单分类
		return request({url:"/api/work_order/workOrderPage",data:upJson})
	},
	addClientWork:function(upJson,type){//客户新增工单
		return request({url:"/api/work_order/addWorkOrder",data:upJson,back:true,type:3})
	},
	
	getWorkList:function(upJson,type){//获取工单列表
		return request({url:"/api/work/lists",data:upJson, methods:"GET"})
	},
	
	
	
	getProduct:function(upJson,type){//获取产品列表
		return request({url:"/api/goods/goodsList",data:upJson})
	},
	
	changePrice:function(upJson,type){//修改产品价格
		return request({url:"/api/goods/changeprice",data:upJson})
	},
	
	getBranchList:function(upJson){//获取部门列表
		return request({url:"/api/common/branch_list", data:upJson,methods:"POST"})
	},
	getUserList:function(upJson){//获取部门人员列表
		return request({url:"/api/common/user",data:upJson, methods:"POST"})
	},
	uploadFile:function(upJson){//文件上传
		return uploadFile({url:"/api/common/upload",data:upJson})
	},
	getTimeString:function(time){//时间转时间戳
		if(time.length == 10){
			time += " 00:00:00";
		}
		time = time.split("-");
		time.length == 2 ? time = time[0] : time = time[0] + '/' + time[1] + '/' + time[2];
		return Date.parse(new Date(time)) / 1000
	},
	prompt:function(title){
		uni.showToast({title,icon:"none"})
	}
}